﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImageDomain.Utils;
public class DcmHelper
{
    /// <summary>
    /// 获取指定目录文件下的所有Dicom文件
    /// </summary>
    /// <param name="dirPath"></param>
    /// <returns></returns>
    public static IList<string> GetAllDicomFiles(string dirPath)
    {
        var rs = new List<string>();
        var dir = new DirectoryInfo(dirPath);
        var files = dir.GetFileSystemInfos();
        if (files.Length == 0) return rs;
        foreach (var fi in files)
        {
            if (fi.Attributes != FileAttributes.Directory &&
                (fi.Extension.Trim() == ".dcm" || fi.Extension.Trim() == ""))
            {
                rs.Add(fi.FullName);
            }
            else if (fi.Attributes == FileAttributes.Directory)
            {
                rs.AddRange(GetAllDicomFiles(fi.FullName));
            }
        }
        return rs;
    }
}
